﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using Yahoo.Yui.Compressor;

namespace ResourceBuilder
{
   class Program
   {
      static void Main(string[] args)
      {
         BuildCssResources();
         Console.WriteLine("{0}{1}{0}", Environment.NewLine, "CSS Resource Build Complete...");
         Console.WriteLine("Click the return key to exit.");
         Console.ReadLine();
      }

      /// <summary>
      /// Builds the design-time and release CSS files.
      /// </summary>
      private static void BuildCssResources()
      {
         DirectoryHelper dh = new DirectoryHelper();

         CssResourceBuilder css = new CssResourceBuilder();

         // build the design-time css
         string resultCss = css.BuildDesignTimeCss();

         using (TextWriter tws = new StreamWriter(Path.Combine(dh.CssAssetsDirectoryPath, Settings1.Default.DesignTimeStylesheet)))
         {
            tws.Write(resultCss);
         }

         // build the release css
         resultCss = css.BuildReleaseCss();

         using (TextWriter tws = new StreamWriter(Path.Combine(dh.CssAssetsDirectoryPath, Settings1.Default.ReleaseStylesheet)))
         {
            tws.Write(CssCompressor.Compress(resultCss));
         }
      }
   }
}
